#include "JdtMesLog.h"

#include <QMessageLogContext>
#include <QString>
#include "LogManager.h"

static void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& msg)
{
	switch (type)
	{
	case QtDebugMsg:
        LogManager::Instance().Debug(msg.toStdWString());
		break;
	case QtInfoMsg:
        LogManager::Instance().Info(msg.toStdWString());
		break;
	case QtWarningMsg:
        LogManager::Instance().Warn(msg.toStdWString());
		break;
	case QtCriticalMsg:
        LogManager::Instance().Critical(msg.toStdWString());
		break;
	default:
        LogManager::Instance().Error(msg.toStdWString());
		break;
	}
}

void Logger::InstallQtMessageHandler()
{
	qInstallMessageHandler(messageHandler);
}